/*
student_index.jsp页面
*/
var currentpage=1;
var totalpage=0;
var currentrecord=1;
/**
 * 每页显示条数
 */
var range=2;
var totalcount=0;
/**
 * pp即perpage，正常与range语义一致，
 * 主要为解决数据库记录数小于range而作为range的拷贝
 */
var pp=range;

var target=null; 

function DataSourceClass(){
	this.getParams = function(){
		var params = {
				"queryOption['planType']":qom('#eventType','poFrame').attr('value'),
				"queryOption['planStatus']":qom('#planStatus','poFrame').attr('value'),
				"queryOption['planScope']":qom('#planScope','poFrame').attr('value'),
				"queryOption['planRegion']":qom('#planRegion','poFrame').attr('value'),
				"queryOption['planGrade']":qom('#planGrade','poFrame').attr('value')
		}; 
		return params;    
    }
}

function BaseClass(){
	this.findPlanRecordCount=function(url){
		qom('#noneTR','poFrame').hide();
		qom('#planTable','poFrame').show();
		qom('#studentTable','poFrame').children().remove();
		qom('#loadingTR','poFrame').show();
		var dsc=new DataSourceClass();
		jQuery.post(url, dsc.getParams(), this.findPlanRecordCountRst, 'json');
	}	
	this.findPlanRecordCountRst=function(data){
		alert(data.recordCount);
		if(data.recordCount==0){
			$('#loadingTR').hide();
			$('#noneTR').show();		
			$('#currpage').text(0);
			$('#countpp').text(0);
			$('#totalpage').text(0);	
			$('#sprecvct').text(0);	
		}else{
			$('#noneTR').hide();
			totalcount=data.recordCount;
			totalpage=Math.ceil(totalcount/range);
			$('#sprecvct').text(totalcount);
			if(totalcount<range){
				pp=totalcount;
			}
			//this.findPartByPage(1,pp);
		}
		
	}	
	/**
	 * 发送异步请求获取分页数据
	 */
	this.findPartByPage=function(first,max){
		$('#studentTable').children().remove();
		$('#loadingTR').show();
		var url = 'lzm/FindPlan_findPlanByOption.action';
		var params = {
				firstRow : first-1,
				maxRow : max,
				"queryOption['planType']":$('#planType').attr('value'),
				"queryOption['planStatus']":$('#planStatus').attr('value'),
				"queryOption['planScope']":$('#planScope').attr('value'),
				"queryOption['planRegion']":$('#planRegion').attr('value'),
				"queryOption['planGrade']":$('#planGrade').attr('value')
		}; 
		jQuery.post(url, params, findPartByPageRst, 'json');
	}
}

function Plan(){

}




function RunClass(){
	target = arguments[0];	
	var bc=new BaseClass();
	bc.findPlanRecordCount(target.getRcdCnt());
	//var bc=new BaseClass();
	//bc.findPlanRecordCount(target.getRcdCnt());
	//alert(target.method3());
	//alert("run");
}












